package com.witmore.neutron.ai.web.utils;

import java.util.Random;

public class RandomCodeGenerator {

    public static String generateRandomCode(int length) {
        String characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
        Random random = new Random();
        StringBuilder sb = new StringBuilder(length);

        for (int i = 0; i < length; i++) {
            int randomIndex = random.nextInt(characters.length());
            sb.append(characters.charAt(randomIndex));
        }

        return sb.toString();
    }

    public static void main(String[] args) {
        String code = generateRandomCode(16); // 生成长度为 16 的随机 Code
        System.out.println("生成的 Code: " + code);
    }
}